Conditions | 5 |
Paths | 40 |
Total Lines | 42 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | 'use strict' |
||
8 | module.exports = function (kit, slug) { |
||
9 | var questions = [] |
||
10 | |||
11 | if (!kit || !kit.length) { |
||
12 | questions.push({ |
||
13 | type: 'autocomplete', |
||
14 | name: 'kit', |
||
15 | message: 'starter kit:', |
||
16 | source: function (answers, input) { |
||
17 | return new Promise(function(resolve) { |
||
18 | Kits.list(function (list) { |
||
19 | resolve(input && input.length ? list.filter(function(value){ |
||
20 | return value.indexOf(input) >= 0 |
||
21 | }) : list) |
||
22 | }) |
||
23 | }) |
||
24 | }, |
||
25 | default: 'basic' |
||
26 | }) |
||
27 | } |
||
28 | |||
29 | // Slug is set |
||
30 | if (!slug || !slug.length) { |
||
31 | questions.push({ |
||
32 | type: 'input', |
||
33 | name: 'slug', |
||
34 | message: 'module name:', |
||
35 | validate: function (value) { |
||
36 | if (value.match(/^([a-z0-9-]+\/)?[a-z0-9-]+$/)) { |
||
37 | return true |
||
38 | } |
||
39 | |||
40 | return 'Module name should only contain lowercase letters, numbers and dashes.' |
||
41 | } |
||
42 | }) |
||
43 | } |
||
44 | |||
45 | // Need to ask for slug |
||
46 | inquirer.prompt(questions).then(function (answers) { |
||
47 | Kit.create(answers.kit || kit, answers.slug || slug) |
||
48 | }) |
||
49 | } |
||
50 |